package com.plian.system.service.pf.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.plian.Tools.*;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.constant.pf.ScoringStatusConstant;
import com.plian.system.constant.sys.FormStatusConstant;
import com.plian.system.constant.sys.FormTypeConstant;
import com.plian.system.dao.sys.user.UserDao;
import com.plian.system.entity.pf.*;
import com.plian.system.entity.sys.Office;
import com.plian.system.mapper.pf.BaseAssessScoreMapper;
import com.plian.system.mapper.pf.BaseEvaluationScoreMapper;
import com.plian.system.mapper.pf.BaseOfficeScoreMapper;
import com.plian.system.mapper.pf.PerformanceScoreMethodMapper;
import com.plian.system.model.CommonCode;
import com.plian.system.model.ListResult;
import com.plian.system.model.R;
import com.plian.system.mybatis.base.BaseFlowService;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.mybatis.search.SearchEntity;
import com.plian.system.mybatis.search.SearchParamEntiy;
import com.plian.system.mybatis.support.Condition;
import com.plian.system.mybatis.support.Query;
import com.plian.system.properties.GzwProperties;
import com.plian.system.service.pf.IBaseOfficeScoreService;
import com.plian.system.service.pf.IEvaluationScoreDetailService;
import com.plian.system.service.pf.IPerformanceScoreService;
import com.plian.system.service.sys.code.IFormCodeService;
import com.plian.system.service.sys.message.IMessageService;
import com.plian.system.service.sys.office.IOfficeService;
import com.plian.system.service.wf.FormWorkflowService;
import com.plian.system.vo.pf.BaseOfficeScoreVO;
import com.plian.system.vo.pf.ScoreMethodVO;
import com.plian.system.wrapper.pf.BaseOfficeScoreWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

import static com.plian.system.constant.sys.FormStatusConstant.UNREVIEWED;

/**
 * @Author: Take-off
 * @Description: TODO
 * @Date: 2023/1/29 10:14 AM
 * @Version: 1.0
 **/
@Slf4j
@Service
@AllArgsConstructor
public class BaseOfficeScoreServiceImpl extends BaseServiceImpl<BaseOfficeScoreMapper, BaseOfficeScore> implements IBaseOfficeScoreService, BaseFlowService {
    private FormWorkflowService formWorkflowService;

    private IFormCodeService formCodeService;

    private IEvaluationScoreDetailService evaluationScoreDetailService;

    private BaseOfficeScoreWrapper baseOfficeScoreWrapper;

    private IOfficeService officeService;

    private IPerformanceScoreService performanceScoreService;

    private GzwProperties gzwProperties;

    private BaseEvaluationScoreMapper evaluationScoreMapper;

    private BaseAssessScoreMapper baseAssessScoreMapper;

    private IMessageService messageService;

    private UserDao userDao;

    private PerformanceScoreMethodMapper scoreMethodMapper;

    @Override
    public boolean saveOrUpdate(BaseOfficeScore baseOfficeScore) {
        if (!Optional.ofNullable(baseOfficeScore.getStatus()).isPresent()){
            if (!Optional.ofNullable(baseOfficeScore.getEvaluationId()).isPresent()) {
                baseOfficeScore.setStatus(FormStatusConstant.STASH);
            }else {
                baseOfficeScore.setStatus(FormStatusConstant.UNREVIEWED);
            }
        }
        if (baseOfficeScore.getStatus().equals(FormStatusConstant.REJECT)){
            baseOfficeScore.setStatus(FormStatusConstant.UNREVIEWED);
        }
        baseOfficeScore.setScoreStatus(ScoringStatusConstant.OFFICE_SCORE_PROGRESS);
        return super.saveOrUpdate(baseOfficeScore);
    }

    @Override
    @Transactional(rollbackFor=RuntimeException.class)
    public boolean deleteLogic(List<Long> ids) {
        for (Long id : ids) {
            BaseOfficeScore baseOfficeScore = getById(id);
            if (baseOfficeScore == null) {
                return false;
            } else if (baseOfficeScore.getStatus() != null &&
                    (baseOfficeScore.getStatus() != FormStatusConstant.STASH && baseOfficeScore.getStatus() != FormStatusConstant.UNREVIEWED)) {
                return false;
            }
            formWorkflowService.deleteProcessInstance(String.valueOf(id));
        }

        boolean result = super.deleteLogic(ids);
        if (result){
            evaluationScoreDetailService.deleteByParentId(ids);
        }
        return result;
    }

    @Override
    @Transactional(rollbackFor=RuntimeException.class)
    public boolean submit(BaseOfficeScore baseOfficeScore) {
        boolean result = saveOrUpdate(baseOfficeScore);
        if (result) {
            Long officeId = baseOfficeScore.getOfficeId();
            Office office = officeService.getById(officeId);
            List<EvaluationScoreDetail> evaluationScoreDetails = baseOfficeScore.getEvaluationScoreDetails();
            if (CollectionUtil.isNotEmpty(evaluationScoreDetails)){
                evaluationScoreDetails.forEach(m ->{
                    m.setBaseScoreId(baseOfficeScore.getId());
                });
                evaluationScoreDetailService.saveBatch(evaluationScoreDetails);
//                for (EvaluationScoreDetail detail : evaluationScoreDetails){
//                    if (detail.getId() != null &&
//                            Optional.ofNullable(detail.getIsDeleted()).isPresent() && detail.getIsDeleted().intValue() == 1) {
//                        evaluationScoreDetailService.removeById(detail.getId());
//                    }else {
//                        if (!Optional.ofNullable(detail.getBaseScoreId()).isPresent()){
//                            detail.setBaseScoreId(baseOfficeScore.getId());
//                            detail.setFillingUnitId(officeId+"");
//                            if (Optional.ofNullable(office).isPresent()){
//                                detail.setFillingUnitName(office.getName());
//                            }
//                        }
//                        evaluationScoreDetailService.saveOrUpdate(detail);
//                    }
//                }
            }
        }
        return result;
    }

    @Override
    public R<BaseOfficeScoreVO> getDetailObj(BaseOfficeScore baseOfficeScore) {
        BaseOfficeScoreVO baseOfficeScoreVO = new BaseOfficeScoreVO();
        Long baseId = baseOfficeScore.getId();
        List<EvaluationScoreDetail> details = new ArrayList<>();
        if (Optional.ofNullable(baseId).isPresent()){
            baseOfficeScore = getById(baseId);
            baseOfficeScoreVO = baseOfficeScoreWrapper.entityToVO(baseOfficeScore);
            //评分细则
            List<EvaluationScoreDetail> scoreDetailList = evaluationScoreDetailService.list(new LambdaQueryWrapper<EvaluationScoreDetail>().eq(EvaluationScoreDetail::getBaseScoreId, baseOfficeScore.getEvaluationId()));
            if (CollectionUtil.isNotEmpty(scoreDetailList)){
                details.addAll(scoreDetailList);
            }
            List<EvaluationScoreDetail> scoreDetails = evaluationScoreDetailService.list(new LambdaQueryWrapper<EvaluationScoreDetail>().eq(EvaluationScoreDetail::getBaseScoreId, baseId));
            if (CollectionUtil.isNotEmpty(scoreDetails)){
                details.addAll(scoreDetails);
            }
        }else {
            //根据单位和年份获取
            List<BaseEvaluationScore> evaluationScores = evaluationScoreMapper.selectList(new LambdaQueryWrapper<BaseEvaluationScore>().eq(BaseEvaluationScore::getFillingYear, baseOfficeScore.getFillingYear())
                    .eq(BaseEvaluationScore::getFillingUnitId, baseOfficeScore.getFillingUnitId()).eq(BaseEvaluationScore::getStatus,3));
            if (CollectionUtil.isNotEmpty(evaluationScores)){
                BaseEvaluationScore baseEvaluationScore = evaluationScores.get(0);
                baseOfficeScoreVO.setEvaluationId(baseEvaluationScore.getId());
                List<EvaluationScoreDetail> scoreDetails = evaluationScoreDetailService.list(new LambdaQueryWrapper<EvaluationScoreDetail>().eq(EvaluationScoreDetail::getBaseScoreId, baseEvaluationScore.getId()));
                if (CollectionUtil.isNotEmpty(scoreDetails)){
                    details.addAll(scoreDetails);
                }
            }
        }
        if (CollectionUtil.isNotEmpty(details)){
            //附件
            evaluationScoreDetailService.setFiles(details);
            baseOfficeScoreVO.setEvaluationScoreDetails(details);
        }
        //考核评分办法
        List<ScoreMethodVO> allScoreMethod = performanceScoreService.getScoreMethodByOffice(baseOfficeScore.getFillingYear(),baseOfficeScore.getOfficeId());
        baseOfficeScoreVO.setScoreMethodVOS(allScoreMethod);
        return R.data(baseOfficeScoreVO);
    }

    @Override
    public ListResult<BaseOfficeScoreVO> list(Query query){
        List<SearchEntity> entityList = query.getSearch();
        if (query.getAscs()==null&&query.getDescs()==null){
            query.setDescs("create_time");
        }
        QueryWrapper<BaseOfficeScore> queryWrapper = SearchParamEntiy.getQueryWrapper(
                Condition.getQueryWrapper(new BaseOfficeScore()), entityList
        );
        //根据登陆权限
        String officeId = TokenUtil.getOfficeId();
        if (Optional.ofNullable(officeId).isPresent() && !officeId.equals(gzwProperties.getAssessmentId()) ){
            queryWrapper.eq("office_id",officeId);
        }

        IPage<BaseOfficeScore> pages = page(Condition.getPage(query), queryWrapper);
        List<BaseOfficeScoreVO> baseOfficeScoreVOS = baseOfficeScoreWrapper.entityToVO(pages.getRecords());

        ListResult<BaseOfficeScoreVO> listResult = new ListResult<>(CommonCode.SUCCESS);
        listResult.setList(baseOfficeScoreVOS);
        listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
        return listResult;
    }

    @Override
    public List<EvaluationScoreDetail> getAllDetailByOrg(String fillingUnitId){
        List<EvaluationScoreDetail> details = new ArrayList<>();
        List<BaseOfficeScore> officeScores = list(new LambdaQueryWrapper<BaseOfficeScore>().eq(BaseOfficeScore::getFillingUnitId, fillingUnitId).eq(BaseOfficeScore::getStatus, 3));
        if (CollectionUtil.isNotEmpty(officeScores)){
            details = evaluationScoreDetailService.list(new LambdaQueryWrapper<EvaluationScoreDetail>().in(EvaluationScoreDetail::getBaseScoreId,
                    officeScores.stream().map(BaseOfficeScore::getId).collect(Collectors.toList())));

        }
        return details;
    }

    @Override
    public HashMap<String,Object> commit(String id) {
        handleStatus(Long.valueOf(id), FormStatusConstant.FLOW);

        //将需要提交的流程变量返回，用于工作流侧
        return new HashMap<String,Object>();
    }

    @Override
    public Boolean finish(String id) {
        Boolean result = handleStatus(Long.valueOf(id), FormStatusConstant.FINISH);
        if (result){
            BaseOfficeScore officeScore = getById(id);
            //自动生成考核处评分
            saveBaseAssessScore(officeScore);
            //修改状态
            updateFinishStatus(officeScore);
        }

        return result;
    }

    @Override
    public void makeAllOffice(String year){
        List<BaseOfficeScore> baseOfficeScores = new ArrayList<>();

        List<BaseEvaluationScore> evaluationScores = evaluationScoreMapper.selectList(Wrappers.<BaseEvaluationScore>lambdaQuery().eq(BaseEvaluationScore::getFillingYear, year));
        if (CollectionUtil.isNotEmpty(evaluationScores)){
            List<Long> baseScoreIds = evaluationScores.stream().map(BaseEvaluationScore::getId).collect(Collectors.toList());
            //企业子项
            List<EvaluationScoreDetail> unitScoreDetails = evaluationScoreDetailService.list(Wrappers.<EvaluationScoreDetail>lambdaQuery().in(EvaluationScoreDetail::getBaseScoreId, baseScoreIds));
            //todo 附件自动生成
//            if (CollectionUtil.isNotEmpty(unitScoreDetails)) {
//                //附件
//                evaluationScoreDetailService.setFiles(unitScoreDetails);
//            }
            //获取指标详情
            List<PerformanceScoreMethod> scoreMethods = scoreMethodMapper.selectList(Wrappers.<PerformanceScoreMethod>lambdaQuery().eq(PerformanceScoreMethod::getIsLast, 1));

            //获取应该填写的责任处室
            Set<Long> officeIds = scoreMethods.stream().map(PerformanceScoreMethod::getReportOffice).collect(Collectors.toSet());
//            Set<Long> officeIds = performanceScoreService.getAllScoreOffice(year);
            //处室名称
            List<Office> offices = officeService.list();
            if (CollectionUtil.isNotEmpty(officeIds)){
                for (BaseEvaluationScore baseEvaluationScore:evaluationScores){
                    //责任处室
                    officeIds.forEach(officeId ->{
                        //创建责任处室单据
                        BaseOfficeScore baseOfficeScore = new BaseOfficeScore();
                        baseOfficeScore.setFillingYear(baseEvaluationScore.getFillingYear());
                        baseOfficeScore.setFillingUnitId(baseEvaluationScore.getFillingUnitId());
                        baseOfficeScore.setOfficeId(officeId);
                        baseOfficeScore.setFormType(FormTypeConstant.PF_BASE_OFFICE +"");
                        baseOfficeScore.setEvaluationId(baseEvaluationScore.getId());
                        baseOfficeScore.setFillingUnitId(baseEvaluationScore.getFillingUnitId());
                        baseOfficeScore.setIsDeleted(0);
                        baseOfficeScore.setStatus(FormStatusConstant.FINISH);
                        baseOfficeScore.setScoreStatus(ScoringStatusConstant.OFFICE_HAS_REVIEWED);
                        //子项
                        List<EvaluationScoreDetail> officeDetails = new ArrayList<>();

                        //创建子项
                        List<Long> scoreBusinessIds = scoreMethods.stream().filter(m -> Optional.ofNullable(m.getReportOffice()).isPresent() && officeId.equals(m.getReportOffice()) ).map(PerformanceScoreMethod::getId).collect(Collectors.toList());
                        //企业填写的
                        List<EvaluationScoreDetail> unitDetails = unitScoreDetails.stream().filter(m -> scoreBusinessIds.contains(m.getBaseBusinessIndicatorsId()) && baseEvaluationScore.getFillingUnitId().equals(m.getFillingUnitId())).collect(Collectors.toList());
                        if (CollectionUtil.isNotEmpty(unitDetails)){
                            for (EvaluationScoreDetail unitDetail:unitDetails){
                                EvaluationScoreDetail officeDetail = new EvaluationScoreDetail();
                                String officeName = offices.stream().filter(m -> officeId.equals(m.getId())).findFirst().get().getName();
                                officeDetail.setBaseBusinessIndicatorsId(unitDetail.getBaseBusinessIndicatorsId());
                                officeDetail.setFillingUnitId(officeId.toString());
                                officeDetail.setFillingUnitName(officeName);
                                officeDetail.setScore(BigDecimal.ZERO);
                                officeDetail.setIsDeleted(0);
                                officeDetails.add(officeDetail);
                            }
                        }
                        baseOfficeScore.setEvaluationScoreDetails(officeDetails);
                        //保存
                        submit(baseOfficeScore);
                    });
                    //考核处评分
                    BaseAssessScore baseAssessScore = new BaseAssessScore();
                    baseAssessScore.setFillingYear(baseEvaluationScore.getFillingYear());
                    baseAssessScore.setFillingUnitId(baseEvaluationScore.getFillingUnitId());
                    baseAssessScore.setOfficeId(Long.valueOf(gzwProperties.getAssessmentId()));
                    baseAssessScore.setFormType(FormTypeConstant.PF_BASE_ASSESS +"");
                    baseAssessScore.setEvaluationId(baseEvaluationScore.getId());
                    baseAssessScore.setIsDeleted(0);
                    baseAssessScore.setStatus(FormStatusConstant.STASH);
                    baseAssessScore.setScoreStatus(ScoringStatusConstant.OFFICE_SCORE_PROGRESS);
                    baseAssessScoreMapper.insert(baseAssessScore);
                }
            }

        }
    }

    /**
     * @Author: Take-off
     * @Description: //TODO 判断是否所有处室都评分并更新
     * @Date: 4:32 PM 2023/1/31
     * @Param: [baseOfficeScore]
     * @return: void
     **/
    private void updateFinishStatus(BaseOfficeScore baseOfficeScore){
        //是否所有处室都评分
        List<BaseOfficeScore> allOfficeScores = list(new LambdaQueryWrapper<BaseOfficeScore>().eq(BaseOfficeScore::getFillingYear, baseOfficeScore.getFillingYear()).eq(BaseOfficeScore::getFillingUnitId,baseOfficeScore .getFillingUnitId()));
        Boolean flag = true;
        for (BaseOfficeScore officeScore:allOfficeScores){
            if (!(ScoringStatusConstant.OFFICE_SCORE_PROGRESS.equals(officeScore.getScoreStatus())
            && officeScore.getStatus() == 3)){
                flag =false;
                break;
            }
        }
        if (flag){
            allOfficeScores.forEach(score ->{
                score.setScoreStatus(ScoringStatusConstant.OFFICE_HAS_REVIEWED);
            });
            saveOrUpdateBatch(allOfficeScores);
            //修改考核处评分
            List<BaseAssessScore> baseAssessScores = baseAssessScoreMapper.selectList(new LambdaQueryWrapper<BaseAssessScore>().eq(BaseAssessScore::getFillingYear, baseOfficeScore.getFillingYear())
                    .eq(BaseAssessScore::getFillingUnitId, baseOfficeScore.getFillingUnitId()));
            if (CollectionUtil.isNotEmpty(baseAssessScores)){
                BaseAssessScore baseAssessScore = baseAssessScores.get(0);
                baseAssessScore.setScoreStatus(ScoringStatusConstant.OFFICE_HAS_REVIEWED);
                baseAssessScoreMapper.updateById(baseAssessScore);
            }
        }

    }

//    /** TODO DEL
//     * @Author: Take-off
//     * @Description: //TODO 发送消息
//     * @Date: 9:24 AM 2023/2/9
//     * @Param: [baseOfficeScore]
//     * @return: void
//     **/
//    @Override
//    public void sendMessage(BaseOfficeScore baseOfficeScore){
//        List<Message> messages = new ArrayList<>();
//        BaseOfficeScore officeScore = getById(baseOfficeScore.getId());
//        BaseOfficeScoreVO baseOfficeScoreVO = baseOfficeScoreWrapper.entityToVO(officeScore);
//        //当前登陆用户
//        String orgId = TokenUtil.getTokenOrgId();
//        String userId = TokenUtil.getTokenUserId();
//        try {
//            PageData findbyid = userDao.findbyid(userId);
//            String name = findbyid.getString("name");
//            //下发处室的人
//            List<PageData> userByOffice = userDao.getUserByOffice(baseOfficeScoreVO.getOfficeId());
//            if (CollectionUtil.isNotEmpty(userByOffice)){
//                for (PageData pageData:userByOffice){
//                    Message message = Message.builder().formId(baseOfficeScoreVO.getId()+"").orgName(baseOfficeScoreVO.getFillingUnitName())
//                            .orgId(orgId).formType(baseOfficeScoreVO.getFormType()).formTypeName("履职成效考评评分").messageTime(DateUtil.now())
//                            .createUser(pageData.getString("id")).message("请尽快完成该家单位履职成效评分").sendUser(userId).sendUserName(name).isIgnore(0).build();
//
//                    messages.add(message);
//                }
//            }
//
//            messageService.saveBatch(messages);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//    }

    /**
     * @Author: Take-off
     * @Description: //TODO 自动生成考核处评分
     * @Date: 6:59 PM 2023/1/29
     * @Param: [baseOfficeScore]
     * @return: void
     **/
    private void saveBaseAssessScore(BaseOfficeScore baseOfficeScore){
        BaseAssessScore baseAssessScore = setBaseBusinessAudit(baseOfficeScore);
        if (!Optional.ofNullable(baseAssessScore.getId()).isPresent()){
            baseAssessScoreMapper.insert(baseAssessScore);
        }
    }

    /**
     * @Author: Take-off
     * @Description: //TODO 生成考核处评分
     * @Date: 6:58 PM 2023/1/29
     * @Param: [baseOfficeScore]
     * @return: com.plian.system.entity.pf.BaseAssessScore
     **/
    private BaseAssessScore setBaseBusinessAudit(BaseOfficeScore baseOfficeScore){
        BaseAssessScore baseAssessScore = new BaseAssessScore();
        List<BaseAssessScore> baseAssessScores = baseAssessScoreMapper.selectList(new LambdaQueryWrapper<BaseAssessScore>().eq(BaseAssessScore::getFillingYear, baseOfficeScore.getFillingYear())
                .eq(BaseAssessScore::getFillingUnitId, baseOfficeScore.getFillingUnitId()));
        if (CollectionUtil.isNotEmpty(baseAssessScores)){
            baseAssessScore = baseAssessScores.get(0);
        }else {
            baseAssessScore.setFillingYear(baseOfficeScore.getFillingYear());
            baseAssessScore.setFillingUnitId(baseOfficeScore.getFillingUnitId());
            baseAssessScore.setOfficeId(Long.valueOf(gzwProperties.getAssessmentId()));
            baseAssessScore.setFormType(FormTypeConstant.PF_BASE_ASSESS +"");
            baseAssessScore.setEvaluationId(baseOfficeScore.getEvaluationId());
            baseAssessScore.setIsDeleted(0);
            baseAssessScore.setStatus(FormStatusConstant.STASH);
            baseAssessScore.setScoreStatus(ScoringStatusConstant.OFFICE_SCORE_PROGRESS);
        }
        return baseAssessScore;
    }


    @Override
    public Boolean reject(String id, int formState,String commont) {
        return handleStatus(Long.valueOf(id), formState);
    }

    @Override
    public void goBackToStash(String formId) {
        handleStatus(Long.valueOf(formId), UNREVIEWED);
    }

    /**
     * 统一处理状态机事件方法
     *
     * @param id          主键
     * @param updateStatus  更新状态
     * @return boolean
     */
    private Boolean handleStatus(Long id, int updateStatus) {
        try {
            BaseOfficeScore baseOfficeScore = getById(id);
            /**
             * 设置审批人和审批时间
             */
            if (updateStatus == FormStatusConstant.FINISH){
                baseOfficeScore.setApprovedUser(TokenUtil.getTokenUserId());
                Date now = DateUtil.now();
                baseOfficeScore.setApprovedTime(now);
            }
            baseOfficeScore.setStatus(updateStatus);
            updateById(baseOfficeScore);
            return true;
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
            return false;
        }
    }

    @Override
    public List<PageData> findByIds(List<String> formIds) {
        LambdaQueryWrapper<BaseOfficeScore> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(BaseOfficeScore::getId, Func.toLongList(StringUtils.join(formIds, StringPool.COMMA)));
        List<BaseOfficeScore> baseOfficeScores = list(queryWrapper);
        List<BaseOfficeScoreVO> baseOfficeScoreVOS = baseOfficeScoreWrapper.entityToVO(baseOfficeScores);
        List<PageData> pageDataList = new ArrayList<>();
        try{
            if (CollectionUtil.isNotEmpty(baseOfficeScoreVOS)){
                for (BaseOfficeScoreVO vo : baseOfficeScoreVOS){
                    PageData pd = new PageData();
                    pd.put("id", vo.getId());
                    pd.put("UNITNAME", vo.getFillingUnitName());
                    pd.put("APPLICANTNAME", vo.getCreateUserName());
                    pd.put("applicantId", vo.getCreateUser());
                    pd.put("applyOrganizationId", vo.getFillingUnitId());
                    pd.put("formType", vo.getFormType());
                    pd.put("orgName", vo.getFillingUnitName());
                    pageDataList.add(pd);
                }
            }

            return pageDataList;
        } catch (Exception e) {
            log.error(ExceptionUtils.getFullStackTrace(e));
        }
        return pageDataList;
    }

    @Override
    public List<Integer> getFormType() {
        return Collections.singletonList(FormTypeConstant.PF_BASE_OFFICE);
    }


}
